package com.zx.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zx.common.annotation.Log;
import com.zx.common.core.controller.BaseController;
import com.zx.common.core.domain.AjaxResult;
import com.zx.common.enums.BusinessType;
import com.zx.pm.domain.ImplementationProject;
import com.zx.pm.service.IImplementationProjectService;
import com.zx.common.utils.poi.ExcelUtil;
import com.zx.common.core.page.TableDataInfo;

/**
 * 实施项目信息Controller
 *
 * @author ruoyi
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/system/project")
public class ImplementationProjectController extends BaseController
{
    @Autowired
    private IImplementationProjectService implementationProjectService;

    /**
     * 查询实施项目信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:project:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImplementationProject implementationProject)
    {
        startPage();
        List<ImplementationProject> list = implementationProjectService.selectImplementationProjectList(implementationProject);
        return getDataTable(list);
    }

    /**
     * 导出实施项目信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:project:export')")
    @Log(title = "实施项目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImplementationProject implementationProject)
    {
        List<ImplementationProject> list = implementationProjectService.selectImplementationProjectList(implementationProject);
        ExcelUtil<ImplementationProject> util = new ExcelUtil<ImplementationProject>(ImplementationProject.class);
        util.exportExcel(response, list, "实施项目信息数据");
    }

    /**
     * 获取实施项目信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(implementationProjectService.selectImplementationProjectById(id));
    }

    /**
     * 新增实施项目信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:add')")
    @Log(title = "实施项目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImplementationProject implementationProject)
    {
        return toAjax(implementationProjectService.insertImplementationProject(implementationProject));
    }

    /**
     * 修改实施项目信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:edit')")
    @Log(title = "实施项目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImplementationProject implementationProject)
    {
        return toAjax(implementationProjectService.updateImplementationProject(implementationProject));
    }

    /**
     * 删除实施项目信息
     */
    @PreAuthorize("@ss.hasPermi('system:project:remove')")
    @Log(title = "实施项目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(implementationProjectService.deleteImplementationProjectByIds(ids));
    }
}
